//-----------------------------------------------------------
//
//-----------------------------------------------------------
class ZFGUI_MainMenu extends UT2K4GUIPage;

// Texture to be strecthed across the window back-ground.
var automated FloatingImage MenuBackground;

// Manages buttons and toggles and anything else GUI
// related that we want it to control. It controls
// placement, etc.
var automated   GUISectionBackground MainMenu_Manager;

var automated   GUIButton SinglePlayer_Button, MultiPlayer_Button, HostGame_Button, Exit_Button;
var localized string SteamMustBeRunningText;

// Attach buttons n' stuff to the Component Manager
function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
    super.InitComponent(MyController, MyOwner);

    MainMenu_Manager.ManageComponent(SinglePlayer_Button);
    MainMenu_Manager.ManageComponent(MultiPlayer_Button);
    MainMenu_Manager.ManageComponent(HostGame_Button);
    MainMenu_Manager.ManageComponent(Exit_Button);
}

// Delegated function that we assign to each
// of our buttons in the default properties
// that gets called whenever the button is clicked.
function bool ButtonClick(GUIComponent Sender)
{
    local GUIButton selected;
    if (GUIButton(Sender) != None)
		selected = GUIButton(Sender);

	switch (sender)
	{
        case SinglePlayer_Button:
	            Profile("InstantAction");
	    		Controller.OpenMenu(Controller.GetInstantActionPage());
	    		Profile("InstantAction");
            break;

       case MultiPlayer_Button:
        	if( !Controller.CheckSteam() )
        	{
            	Controller.OpenMenu(Controller.QuestionMenuClass);
		    	GUIQuestionPage(Controller.TopPage()).SetupQuestion(SteamMustBeRunningText, QBTN_Ok, QBTN_Ok);
        	}
        	else
        	{
	            Profile("ServerBrowser");
				Controller.OpenMenu(Controller.GetServerBrowserPage());
				Profile("ServerBrowser");
        	}
			break;

		case HostGame_Button:
        	if( !Controller.CheckSteam() )
        	{
            	Controller.OpenMenu(Controller.QuestionMenuClass);
		    	GUIQuestionPage(Controller.TopPage()).SetupQuestion(SteamMustBeRunningText, QBTN_Ok, QBTN_Ok);
        	}
        	else
        	{
		        Profile("MPHost");
				Controller.OpenMenu(Controller.GetMultiplayerPage());
				Profile("MPHost");
        	}
 	        break;

    	case Exit_Button:
    	    Profile("Quit");
    		Controller.OpenMenu(Controller.GetQuitPage());
    		Profile("Quit");
    	    break;

	}

    /*
	if ( Sender == b_ModsAndDemo )
	{
			Profile("ModsandDemos");
			Controller.OpenMenu(Controller.GetModPage());
     		profile("ModsandDemos");
	}
	*/

	return true;
}

defaultproperties
{
	WinWidth=1
	WinHeight=1
	WinLeft=0
	WinTop=0

    // BACKGROUND
    Begin Object Class=FloatingImage Name=FloatingBackground
        Image=Texture'ZombieMod.Shared.ZombieFest'
        DropShadow=None
        ImageStyle=ISTY_Scaled
        ImageRenderStyle=MSTY_Normal
        WinTop=0.0
        WinLeft=0.000000
        WinWidth=1.000000
        WinHeight=1.0
        RenderWeight=0.000003
    End Object
    MenuBackground=FloatingBackground

    // GUI MANAGER
    Begin Object class=ROGUIContainerNoSkinAlt Name=MainMenu_RealManager
		WinWidth=0.485000
		WinHeight=0.281354
		WinLeft=0.021875
		WinTop=0.694000
        //RenderWeight=0.01
	End Object
	MainMenu_Manager=MainMenu_RealManager

    // SINGLEPLAYER/PRACTICE GAME BUTTON
   	Begin Object Class=GUIButton Name=SinglePlayer_RealButton
        Caption="Single-Player"
        //bAutoSize=True
        bAutoShrink=False
        FontScale=FNS_Large
		CaptionAlign=TXTA_Left
        CaptionEffectStyleName="TextButtonEffect"
        StyleName="TextButton"
        Hint="Pwn some zombies on your own!"
        TabOrder=0
        bFocusOnWatch=True
        OnClick=ButtonClick
        OnKeyEvent=GUIButton.InternalOnKeyEvent
        bUseCaptionHeight=true
    End Object
    SinglePlayer_Button=GUIButton'SinglePlayer_RealButton';

    // MULTIPLAYER JOIN GAME BUTTON
   	Begin Object Class=GUIButton Name=MultiPlayer_RealButton
        Caption="Multi-Player"
        //bAutoSize=True
        bAutoShrink=False
        FontScale=FNS_Large
		CaptionAlign=TXTA_Left
        CaptionEffectStyleName="TextButtonEffect"
        StyleName="TextButton"
        Hint="Pwn some zombies with friends, or just pwn friends with zombies around!"
        TabOrder=1
        bFocusOnWatch=True
        OnClick=ButtonClick
        OnKeyEvent=GUIButton.InternalOnKeyEvent
        bUseCaptionHeight=true
    End Object
    MultiPlayer_Button=GUIButton'MultiPlayer_RealButton';

    // HOST MP GAME BUTTON
   	Begin Object Class=GUIButton Name=HostGame_RealButton
        Caption="Host Game"
        //bAutoSize=True
        bAutoShrink=False
        FontScale=FNS_Large
		CaptionAlign=TXTA_Left
        CaptionEffectStyleName="TextButtonEffect"
        StyleName="TextButton"
        Hint="Make it your rules, your epocalypse!"
        TabOrder=2
        bFocusOnWatch=True
        OnClick=ButtonClick
        OnKeyEvent=GUIButton.InternalOnKeyEvent
        bUseCaptionHeight=true
    End Object
    HostGame_Button=GUIButton'HostGame_RealButton';

    Begin Object Class=GUIButton name=Exit_RealButton
		Caption="Exit"
		//bAutoSize=True
        bAutoShrink=False
		OnClick=ButtonClick
		CaptionAlign=TXTA_Left
        FontScale=FNS_Large
        CaptionEffectStyleName="TextButtonEffect"
        StyleName="TextButton"
        Hint="Exit the zombie slaughter!"
        TabOrder=3
        bFocusOnWatch=True
        bUseCaptionHeight=true
	End Object
	Exit_Button=GUIButton'Exit_RealButton'

	SteamMustBeRunningText = "Yo Cap'n. You must be connected to zee steam playa's house to connects you hearz?"
}
